package com.fh.wanandroid.ui.wx.presenter;

import android.util.Log;

import com.fh.wanandroid.base.BaseResponse;
import com.fh.wanandroid.net.RetrofitHelper;
import com.fh.wanandroid.ui.knowledge.KnowledgeDataList;
import com.fh.wanandroid.ui.knowledge.contract.KnowledgeContract;
import com.fh.wanandroid.ui.wx.bean.WXAuthorListData;
import com.fh.wanandroid.ui.wx.contract.WXArticleContract;
import com.fh.wanandroid.utils.NetErrorUtil;

import java.util.List;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

public class WXAuthorPresenter extends  WXArticleContract.Presenter {

    @Override
    public void getWxAuthorListData() {

        mCompositeDisposable.add(RetrofitHelper.createArticleApi().getWXAuthor()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<BaseResponse<List<WXAuthorListData>>>() {
                    @Override
                    public void accept(BaseResponse<List<WXAuthorListData>> wxAuthorListData) throws Exception {
                        mView.showWXAutor(wxAuthorListData);
//                        Log.e("wxAuthorListData", "------------------wxAuthorListData:"+wxAuthorListData.getData().get(0).getName());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable t) throws Exception {
//                        mView.loadArticlesFail(NetErrorUtil.handleThrowable(t));
                        mView.loadDataFail(NetErrorUtil.handleThrowable(t));
                    }
                }));

    }
}